package com.eh.proxy.remote.client;

import com.eh.proxy.remote.remote.model.GumballMachineRemote;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;

/**
 * Created by David on 2016/5/2.
 */
public class GumballMachineClientDriveTest {
    public static void main(String[] args) {
        try {
            GumballMachineRemote machine = (GumballMachineRemote) Naming.lookup("rmi://127.0.0.1:6600/bj_gumballMachine");
            GumballMachineMonitor monitor = new GumballMachineMonitor(machine);
            while (true) {
                monitor.report();
                Thread.sleep(1000L);
            }
        } catch (RemoteException e) {
            e.printStackTrace();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (NotBoundException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
